package Year22_Month04.day04;

import java.util.Scanner;

public class 不用运算符做加法 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(sum(a,b));
            System.out.println(sum(a,subtraction(b)));
        }
    }

    public static void main1(String[] args) {
        int a = 5;
        int b = 17;
        System.out.println(Integer.toBinaryString(a));
        System.out.println(Integer.toBinaryString(b));
        System.out.println(Integer.toBinaryString(b&a));
        System.out.println(a^b);
    }

    public static int sum(int a,int b){
        int c = 0;
        while(b != 0){
            c = a ^ b;
            b = (a & b) << 1;
            a = c;
        }
        return a;
    }
    //这里是求相反数
    public static int subtraction(int a){

        return sum(~a,1);
    }


}
